<?php		
/**
 * @version		$Id: link.php 2011.08.11 thierry $
 * @package		admin.models
 * @subpackage	com_projid
 * @copyright	Copyright (C) 2011 Pojid All rights reserved.
 * @license		GNU General Public License version 2 or later; see LICENSE.txt
 */
defined('_JEXEC') or die('Restricted access');
jimport('joomla.application.component.modeladmin');

class ProjidModelLink extends JModelAdmin
	{
	
		public function getTable($type = 'Link', $prefix = 'ProjidTable', $config = array()) 
			{
				return JTable::getInstance($type, $prefix, $config);
			}
		
		public function getForm($data = array(), $loadData = true) 
			{
				// Get the form.
				$form = $this->loadForm('com_projid.link', 'link', array('control' => 'jform', 'load_data' => $loadData));
				if (empty($form)) 
				{
					return false;
				}
				return $form;
			}
public function getParam()
	{

        $db = JFactory::getDBO();
		$query = $db->getQuery(true);

		// Select some fields
		$query->select('id_birt,param_name');
		// From the hello table
		$query->from('#__projid_birt');
		$query->leftjoin('#__projid_report_param  on #__projid_birt.id_birt=#__projid_report_param.report_id');
		$query->leftjoin('#__projid_birt_parameter  on #__projid_report_param.param_id=#__projid_birt_parameter.id_param');
		//$query->where('#__projid_report_param.report_id=#__projid_birt.id_birt');
		
        $items  = $this->_getList((string) $query, $this->getState('list.start'), $this->getState('list.limit'));
 
        // Check for a database error.
        if ($this->_db->getErrorNum()) {
                $this->setError($this->_db->getErrorMsg());
                return false;
        }
 
 return $items;


}
		protected function loadFormData() 
			{
				// Check the session for previously entered form data.
				$data = JFactory::getApplication()->getUserState('com_projid.edit.birt.data', array());
				if (empty($data)) 
				{
					$data = $this->getItem();
				}
				return $data;
			}
	}
